set relativenumber number
set nocompatible
set ignorecase smartcase
let mapleader = "\<space>"

" 缩进与格式
filetype indent on
set autoindent
set smarttab
set cindent
set shiftwidth=2
set tabstop=2
set expandtab
set softtabstop=2
set backspace=eol,start,indent

" 优化jk设置
nnoremap j gj
nnoremap k gk
xnoremap j gj
xnoremap k gk

" mini.move
" alt+hjkl 移动行 可视模式
" nnoremap <M-j> :m +1<CR>==
vnoremap <M-j> :m '>+1<CR>gv=gv
" nnoremap <M-k> :m -2<CR>==
vnoremap <M-k> :m '<-2<CR>gv=gv
" nnoremap <M-h> <<
vnoremap <M-h> <gv
" nnoremap <M-l> >>
vnoremap <M-l> >gv

" H, L jump to line home / end
nnoremap H ^
nnoremap L $
vnoremap H ^
vnoremap L $
onoremap H ^
onoremap L $

" switch window
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l

" create window
nnoremap <leader>sv <C-w>v
nnoremap <leader>sh <C-w>s

nnoremap <C-tab> :bnext<CR>

" 清除搜索高亮
nnoremap <esc><esc> :nohlsearch<return><esc>

" 删除光标前的所有文本
inoremap <C-u> <C-g>u<C-u>
" 删除光标前的单词
inoremap <C-w> <C-g>u<C-w>

" 这些文件类型按q退出
autocmd FileType qf,help,man,checkhealth,startuptime nnoremap <silent><buffer> q <cmd>close<CR>

